<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*,java.sql.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>alter.jsp</title>
</head>
<body>
	<%!public static final String DBDRIVER = "com.mysql.jdbc.Driver";
	public static final String DBURL = "jdbc:mysql://localhost:3306/smm";
	public static final String DBUSER = "root";
	public static final String DBPASS = "657287";%>
	<%
		request.setCharacterEncoding("UTF-8");

		String username = (String) request.getParameter("username");
		String gender = (String) request.getParameter("gender");
		int age = Integer.parseInt(request.getParameter("age"));
		String email = (String) request.getParameter("email");
		String password = (String) request.getParameter("password");
		
		Connection con = null;
		PreparedStatement stat = null;
		try {
			Class.forName(DBDRIVER);
			con = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
			String sql = "update user set gender=?,age=?,email=?,password=? where username=?";
			stat = con.prepareStatement(sql);
			stat.setString(1, gender);
			stat.setInt(2, age);
			stat.setString(3, email);
			stat.setString(4, password);
			stat.setString(5, username);
			stat.executeUpdate();
	%>
	<jsp:forward page="index.jsp">
		<jsp:param value="<%=username%>" name="user" />
	</jsp:forward>
	<%
		} catch (Exception e) {
	%>
	<h3>error!</h3>
	<%
		e.printStackTrace();
		}
	%>
</body>
</html>